#include <stdlib.h>
#include "CardDealer.h"

void CardDealer::Init(int aDeckSize)
{
	deckSize = aDeckSize;
	currentDeckSize = deckSize;

	cardsLeft = new int[deckSize];

	for(int i=0;i<deckSize;++i)
		cardsLeft[i] = i;
}

int CardDealer::dealCard()
{
	if(currentDeckSize<=0)
		return -1;
	int num = rand()%currentDeckSize;
	int pick = cardsLeft[num];
	currentDeckSize--;
	for(int i=num;i<currentDeckSize;++i)
		cardsLeft[i] = cardsLeft[i+1];
	return pick;
}